<?php
declare (strict_types=1);

namespace app\command;

use app\factory\PayHandle;
use app\model\order\OrderItemModel;
use app\model\order\OrderModel;
use app\model\user\UserBeanLogModel;
use app\model\user\UserEarningsPredictModel;
use app\model\user\UserModel;
use think\console\Command;
use think\console\Input;
use think\console\Output;

/**
 * 指令-检测订单-7天收货
 * Class CheckOrderTask
 * @package app\command
 */
class CheckOrderTask extends Command
{
    protected function configure()
    {
        $this->setName('check_order_task_timeout')->setDescription('the check_order_task_timeout command');
    }

    protected function execute(Input $input, Output $output)
    {
//
//        $day = date("Y-m-d");
//        UserModel::upOrderNow(218, $day);
//        OrderItemModel::clearEarnings(218);
//        $pay_sn = "pay20221014114802887128"; //我的支付编号
//        $price = "399597"; //支付金额
//        $res = PayHandle::pay_handle($pay_sn, $price, 'weixin');//支付处理
//        print_r($res);
//        $order_model = new OrderModel();
//        $res = $order_model->cancelOrder(205, 104);
//        print_r($res);
//        print_r("执行：CheckOrderTask");
        $order_model = new OrderModel();
        $res = $order_model->updateTask();//自动收货
        echo "success";
//        UserBeanLogModel::changeEarningsBean(45, 450, 'recharge', "(本金)购买大礼包赠送补发");
//        UserBeanLogModel::changeEarningsBean(48, 4000, 'recharge', "平台充值");
//        UserBeanLogModel::changeEarningsBean(11, 10000, 'recharge', "平台充值");
//        UserBeanLogModel::changeEarningsBean(17,10000, 'recharge', "平台充值");
//        UserBeanLogModel::changeEarnings(29, 10000, 'recharge', "平台充值");
//        $game_model = new GameProcessModel();
//        $game_list = $game_model->where('settlement', 0)->select();
//        foreach ($game_list as $value) {
//            UserModel::upGameNow($value['user_id'], $value['return_bean'], date("Y-m-d", $value['add_time']), $value['id']);
//        }
//        $order_model = new OrderModel();
//        $order_list = $order_model->where('goods_type', 0)->where('order_status', '>', 1)->field('id,pay_date')->select();
//
//        foreach ($order_list as $value) {
////            echo date("Y-m-d H:i:s",$value['pay_date'])."--";
//            UserModel::upOrderNow($value['id'], date("Y-m-d", $value['pay_date']));
//        }
//        $order_item_model = new OrderItemModel();
//        $map = [
//            'goods_type' => 0,
//            'settlement' => 1
//        ];
//        $list_item = $order_item_model->where($map)->where('order_status', '>', 1)->field('id')->select();
//        foreach ($list_item as $value) {
//            UserEarningsPredictModel::clearEarnings($value['id']);
//        }

//        $game_model = new GameProcessModel();
//        $map = [
//            'settlement' => 1
//        ];
//        $list_item = $game_model->where($map)->group('day')->field('day')->select();
//        foreach ($list_item as $value) {
//            UserBeanPredictModel::clearEarnings($value['day']);
//        }

//        UserModel::upOrderNow(197, "2022-10-12");
    }
}
